﻿@using mscook.mvc;
<div class="span12 center">
    <div class="dataTables_paginate paging_bootstrap pagination" id="pageBreak">
        <ul>
            @if (!ViewData[ViewDataKeys.CURRENT_PAGE].ToString().Equals("1"))
            {
                var prePage = Int32.Parse(ViewData[ViewDataKeys.CURRENT_PAGE].ToString()) - 1;
                // var href = ViewData[ViewDataKeys.HRRF].ToString() + prePage;
                <li class="prev"><a data-num="@prePage" href="javaScript:void(0)" data-link-btn="@ViewData["linkBtn"]">← 上一页</a></li>
            }
            else
            {
                <li class="prev disabled"><a href='javaScript:void(0)'>← 上一页</a></li>
            }

            <!--显示“页数”的样式-->
            @for (var i = 0; i < ViewBag.PageList.Length; i++)
            {
                var item = ViewBag.PageList[i];
                if (!item.ToString().Equals("0"))
                {
                    if (ViewData[ViewDataKeys.CURRENT_PAGE].ToString().Equals(item.ToString()))
                    {
                <li class="active"><a href="javaScript:void(0)">@item</a></li>
                    }
                    else
                    {
                        // var href = ViewData[ViewDataKeys.HRRF].ToString() + item;
                <li><a href="javaScript:void(0)" data-num="@item" data-link-btn="@ViewData["linkBtn"]">@item</a></li>
                    }
                }
            }

            <!--显示“下一页”的样式-->
            @if (!ViewData[ViewDataKeys.TOTAL_PAGE].ToString().Equals("0") && !ViewData[ViewDataKeys.CURRENT_PAGE].ToString().Equals(ViewData[ViewDataKeys.TOTAL_PAGE].ToString()))
            {
                var nextPage = Int32.Parse(ViewData[ViewDataKeys.CURRENT_PAGE].ToString()) + 1;
                //  var href = ViewData[ViewDataKeys.HRRF].ToString() + nextPage;
                <li class="prev"><a href="javaScript:void(0)" data-num="@nextPage" data-link-btn="@ViewData["linkBtn"]">下一页 →</a></li>
                   
            }
            else
            {
                <li class="next disabled"><a href="javaScript:void(0)">下一页 →</a></li>
            }
        </ul>
    </div>
</div>

<script type="text/javascript">
    jQuery(document).ready(function ($) {

        @{
            <text>
        //var linkBtn = "@ViewData["linkBtn"]";
        //alert(linkBtn);
        $("#pageBreak li a").live("click", function () {
            var pageNum = $(this).data("num");
            var linkBtn = $(this).data("link-btn");
            if (pageNum != undefined && pageNum != null) {
                var link = $("#" + linkBtn);
                link.attr("data-num", pageNum);
                link.click();
            }
            return false;
        });

        $(".searchForm button.search").live("click", function () {
            var data = $(this).parents("form").serialize();
            var linkBtn = $(this).data("link-btn");
            var link = $("#" + linkBtn);
            link.attr("data-num", "1");
            link.attr("data-search",data);
            link.click()
            return false;
        });

        </text>
        }




    });
</script>

